package ${package.ServiceImpl};

import com.baomidou.mybatisplus.core.metadata.IPage;
import ${cfg.QueryConditionDTO};
import ${cfg.QueryConditionUtils};
import ${cfg.Assert};
import ${cfg.PageQuery};
import ${cfg.PagedResult};
import ${cfg.dtoPackage}.${entity}PageDTO;
import ${cfg.dtoPackage}.${entity}ListDTO;
import ${cfg.dtoPackage}.${entity}DTO;
import ${cfg.boPackage}.${entity}BO;
import ${cfg.boPackage}.${entity}PageBO;
import ${cfg.boPackage}.${entity}ListBO;
import ${cfg.convertPackage}.${entity}Convert;
import java.util.List;
import ${package.Entity}.${entity};
import ${package.Entity}.${entity}PageDO;
import ${package.Entity}.${entity}ListDO;
import ${package.Mapper}.${table.mapperName};
import ${package.Service}.${table.serviceName};
import ${superServiceImplClassPackage};
import org.springframework.stereotype.Service;

@Service
<#if kotlin>
open class ${table.serviceImplName} : ${superServiceImplClass}<${table.mapperName}, ${entity}>(), ${table.serviceName} {

}
<#else>
public class ${table.serviceImplName} extends ${superServiceImplClass}<${table.mapperName}, ${entity}> implements ${table.serviceName} {

    @Override
    public PagedResult<${entity}PageBO> getPageList(PageQuery query, List<QueryConditionDTO> queryConditions, ${entity}PageDTO pageDTO) {
        IPage<${entity}PageDO> page = this.baseMapper.getPageList(
                QueryConditionUtils.getPagination(query),
                queryConditions,
                pageDTO);
        return ${entity}Convert.INSTANCE.convert(page);
    }

    @Override
    public List<${entity}ListBO> getList(List<QueryConditionDTO> queryCondition, ${entity}ListDTO dto) {
        List<${entity}ListDO> ${table.entityPath}List = this.baseMapper.getList(queryCondition, dto);
        return ${entity}Convert.INSTANCE.convert(${table.entityPath}List);
    }

    @Override
    public ${entity}BO getDetailById(Long id) {
        ${entity} ${table.entityPath} = getById(id);
        Assert.notNull(${table.entityPath}, "${table.entityPath} is null!");
        return ${entity}Convert.INSTANCE.convert(${table.entityPath});
    }

    @Override
    public boolean save(${entity}DTO dto){
        ${entity} new${entity} = ${entity}Convert.INSTANCE.convert(dto);
        return save(new${entity});
    }

    @Override
    public boolean updateById(Long id, ${entity}DTO dto){
        ${entity} old${entity} = getById(id);
        Assert.notNull(old${entity}, "${table.entityPath} is null!");
        ${entity} new${entity} = ${entity}Convert.INSTANCE.convert(dto);
        new${entity}.setId(id);
        return updateById(new${entity});
    }
}
</#if>
